package com.itlong.cloud.app.resource;

import com.itlong.cloud.POJO.VO.app.robot.AppRobotAccountInfoGetVO;
import com.itlong.cloud.POJO.VO.app.robot.AppRobotProjectInfoVO;
import com.itlong.cloud.app.service.IAppRobotLoginService;
import com.itlong.cloud.user.app.IAppRobotLoginServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *     机器人APP登录暴露接口实现类
 * </desc>
 *
 * @createDate 2018/10/15
 */
@RestController
public class AppRobotLoginServiceResource implements IAppRobotLoginServiceClient {

    @Autowired
    private IAppRobotLoginService iAppRobotLoginService;

    /**
     * <desc>
     *      获取机器人登录账号信息
     * </desc>
     *
     * @param account 账号
     * @return 账号信息
     * @author wangzhi
     * @createDate 2018/10/15
     */
    @Override
    @PostMapping(path = "app/robot/getRobotUserByAccount")
    public AppRobotAccountInfoGetVO getRobotUserByAccount(@RequestParam("account") String account) throws Exception {
        return iAppRobotLoginService.getRobotUserByAccount(account);
    }

    /**
     * <desc>
     *      获取项目id列表
     * </desc>
     *
     * @param userId 开发者账号用户id
     * @return
     * @Author Zhu.yj
     * @createDate  2020/8/3
     */
    @Override
    @RequestMapping("/app/robot/getProjectIdList")
    public List<AppRobotProjectInfoVO> getProjectIdList(@RequestParam String userId) throws Exception {
        return iAppRobotLoginService.getProjectIdList(userId);
    }

    /**
     * <desc>
     *      切换项目
     * </desc>
     *
     * @param projectId 项目id
     * @return
     * @Author Zhu.yj
     * @createDate  2020/8/4
     */
    @RequestMapping(value = "/app/robot/changeProject", method = RequestMethod.POST)
    @Override
    public AppRobotProjectInfoVO changeProject(@RequestParam("projectId") String projectId,@RequestParam("userId") String userId) throws Exception {
        return iAppRobotLoginService.changeProject(projectId,userId);
    }
}
